<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'product.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item>LRP计划单</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <d-splitter orientation="vertical" disabledBarSize="1px" [splitBarSize]="splitBarSize" style="height: 100%"
      [showCollapseButton]="true">
      <d-splitter-pane minSize="50%" [size]="partDetailHeight">
        <div class="da-list-container ">
          <div class="da-list-header">
            <div class="d-input">
              <div class="inputIn">
                <input dTextInput style="width: 180px;" [error]="false" placeholder="LRP单号" name="filterRole"
                  class="me-2" [(ngModel)]="JobOrderNum">
                <d-select style="width: 180px;" [options]="stateOptions" placeholder="状态" [(ngModel)]="JobOrderStatus"
                  class="me-2"></d-select>
                <d-range-datepicker-pro [(ngModel)]="rangeDate" (ngModelChange)="rangeDateChange($event)"
                  name="rangeDate" [placeholder]="['制单时间-开始','制单时间-结束']" class="me-2"></d-range-datepicker-pro>
                <input dTextInput style="width: 180px;" [error]="false" placeholder="单据类型" name="filterRole"
                  class="me-2" [(ngModel)]="JobOrderType">
                <div class="d-submit">
                  <d-button id="primaryBtn" (click)="search2()"><i class="icon icon-filter-o me-2"></i>查询</d-button>
                  <d-button bsStyle="common" (click)="reset()"> <i class="icon icon-refresh me-2"></i>重置</d-button>
                </div>
              </div>
            </div>
            <div class="btn-group">
              <div class="btn-left">
                <d-button bsStyle="primary" routerLink="/pages/product/add-lrp"> <i
                    class="icon icon-add me-2"></i>新增LRP计划
                </d-button>
                <d-button bsStyle="common" routerLink="/pages/product/add-product-job">发起审核</d-button>
                <d-button bsStyle="danger" (btnClick)="deletes()"><i class="icon icon-delete me-2"></i>删除</d-button>
                <d-button bsStyle="common" (btnClick)="allLog()">日志</d-button>
              </div>
            </div>
          </div>
          <div class="list-content">
            <d-data-table [dataSource]="tableData" [lazy]="true" [scrollable]="true" [fixHeader]="true"
              [tableWidthConfig]="tableWidthConfig" [tableOverflowType]="'auto'" [scrollable]="true"
              (checkAllChange)="getCheckedRows()" (rowCheckChange)="getCheckedRows()" [resizeable]="true">
              <thead dTableHead [checkable]="true">
                <tr dTableRow>
                  <th dHeadCell [fixedLeft]="'80px'">
                    <span>操作</span>
                  </th>
                  <th dHeadCell [fixedLeft]="colOption.fixedLeft" [fixedRight]="colOption.fixedRight"
                    *ngFor="let colOption of dataTableOptions.columns" [title]="colOption.header">{{colOption.header}}
                  </th>
                </tr>
              </thead>
              <tbody dTableBody>
                <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex" let-nestedIndex="nestedIndex">
                  <tr dTableRow (click)="showDetail(rowItem, rowIndex)">
                    <td dTableCell [fixedLeft]="'0px'">
                      <d-checkbox [disabled]="false" [showAnimation]="true" [ngModelOptions]="{ standalone: true }"
                        [ngModel]="rowItem.$checked" dTooltip [halfchecked]="rowItem.$halfChecked"
                        [showGlowStyle]="false"
                        (ngModelChange)="onRowCheckChange($event, rowIndex, nestedIndex, rowItem)"></d-checkbox>
                    </td>
                    <td dTableCell [rowItem]="rowItem" [fixedLeft]="'80px'">
                      <span><a class="devui-link" (click)="analyse(rowItem)"
                          [class.disabled]="rowItem.approvalStatus !== '审核通过'">分析</a></span>
                      <span class="ms-3"><a (click)="Approval(rowItem.id)" class="devui-link">审核</a></span>
                      <span class="ms-3"><a (click)="EditJob(rowItem.id)" class="devui-link"
                          [class.disabled]="rowItem.approvalStatus !=='未开始审核'">编辑</a></span>
                      <span class="ms-3"><a (click)="delete(rowItem.id)" class="devui-link-danger"
                          [class.disabled]="rowItem.approvalStatus == '审核通过' || rowItem.approvalStatus == '审核中'"
                          [class.disabled]="rowItem.approvalStatus">删除</a></span>
                    </td>
                    <td dTableCell [rowItem]="rowItem" [fixedLeft]="'300px'">
                      <span dTooltip [content]="rowItem.lrpNum">{{rowItem.lrpNum}}</span>
                    </td>
                    <td dTableCell [rowItem]="rowItem">
                      <span dTooltip [content]="rowItem.lrpType || '/'">{{rowItem.lrpType || '/'}}</span>
                    </td>
                    <td dTableCell [rowItem]="rowItem">
                      <span dTooltip [content]="rowItem.status">
                        <d-tag [tag]="rowItem.status" [labelStyle]="rowItem.status"></d-tag>
                      </span>
                    </td>
                    <td dTableCell [rowItem]="rowItem">
                      <span dTooltip [content]="rowItem.note">{{rowItem.note }}</span>
                    </td>
                    <td dTableCell [rowItem]="rowItem">
                      <span dTooltip [content]="'查看日志'" (click)="GetLogsById(rowItem.id)">
                        <a class="devui-link">查看</a>
                      </span>
                    </td>
                    <td dTableCell [rowItem]="rowItem">
                      <span dTooltip [content]="rowItem.creator">{{rowItem.creator}}</span>
                    </td>
                    <td dTableCell [rowItem]="rowItem">
                      <span dTooltip [content]="rowItem.createTime">{{rowItem.createTime}}</span>
                    </td>
                    <td dTableCell [rowItem]="rowItem" [fixedRight]="'0px'">
                      <span dTooltip [content]="rowItem.approvalStatus">
                        <d-tag [tag]="rowItem.approvalStatus" [labelStyle]="rowItem.approvalStatus"></d-tag>
                      </span>
                    </td>
                  </tr>
                </ng-template>
              </tbody>
            </d-data-table>
          </div>
          <div class="page-footer">
            <div>
              <p>已选 <span class="underline">{{checkedIds.length}}</span> 条
                <a (click)="cleared()" class="clear">清空</a>
              </p>
            </div>
            <d-pagination [size]="'sm'" [canViewTotal]="true" [canChangePageSize]="true" [canJumpPage]="true"
              [maxItems]="5" [total]="this.pager.total" [pageSizeOptions]="this.pageSizeOptions"
              [(pageSize)]="pager.pageSize" [(pageIndex)]="pager.pageIndex" (pageIndexChange)="pageIndexChange($event)"
              (pageSizeChange)="pageSizeChange($event)">
            </d-pagination>
          </div>
        </div>
      </d-splitter-pane>
      <d-splitter-pane class="detailTable" style="overflow: hidden;" [collapsible]="true">
        <div class="da-list-container">
          <div class="list-content">
            <d-data-table [dataSource]="partDetail" [lazy]="true" [scrollable]="true" [fixHeader]="true"
              [tableWidthConfig]="tableWidthConfig2" [tableOverflowType]="'auto'" [scrollable]="true"
              [resizeable]="true">
              <thead dTableHead>
                <tr dTableRow>
                  <th dHeadCell *ngFor="let colOption of dataTableOptions2.columns">{{ colOption.header }}</th>
                </tr>
              </thead>
              <tbody dTableBody>
                <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex">
                  <tr dTableRow>
                    <td dTableCell>
                      <span dTooltip [content]="rowItem.partNum">{{rowItem.partNum}}</span>
                    </td>
                    <td dTableCell>
                      <span>
                        <div dImagePreview>
                          <d-badge *ngIf="rowItem.image" [count]="getImagesArray(rowItem.image).length"
                            status="success">
                            <ng-container *ngFor="let imageUrl of getImagesArray(rowItem.image); let i = index">
                              <img *ngIf="getImagesArray(rowItem.image).length > 0" [src]="imageUrl" alt="图片"
                                height="22px" [ngStyle]="{'display': i === 0 ? 'block' : 'none'}" />
                            </ng-container>
                          </d-badge>
                        </div>
                      </span>
                    </td>
                    <td dTableCell>
                      <span dTooltip [content]="rowItem.partName">{{rowItem.partName}}</span>
                    </td>
                    <td dTableCell>
                      <span dTooltip [content]="rowItem.partType">{{rowItem.partType}}</span>
                    </td>

                    <td dTableCell>
                      <span dTooltip [content]="rowItem.description">{{rowItem.description}}</span>
                    </td>
                    <td dTableCell>
                      <span dTooltip [content]="rowItem.partUOM">{{rowItem.partUOM}}</span>
                    </td>

                    <td dTableCell>
                      <span dTooltip [content]="rowItem.quantity">{{rowItem.quantity}}</span>
                    </td>
                    <td dTableCell>
                      <span dTooltip [content]="rowItem.sourceOrderNum">{{rowItem.sourceOrderNum}}</span>
                    </td>
                    <td dTableCell>
                      <span dTooltip [content]="rowItem.note">{{rowItem.note}}</span>
                    </td>
                  </tr>
                </ng-template>
              </tbody>
            </d-data-table>
          </div>
        </div>
      </d-splitter-pane>

    </d-splitter>


  </div>
</div>
<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
